package _03振兴中华;


public class _03_振兴中华1 {
    String indexsString[] = {"从", "我", "做", "起", "振", "兴", "中", "华"};
    String s[][] = {
            {"从", "我", "做", "起", "振"},
            {"我", "做", "起", "振", "兴"},
            {"做", "起", "振", "兴", "中"},
            {"起", "振", "兴", "中", "华"}
    };

    private int stepForward(int i, int j, int index) {
        if (i < 4 && j < 5) {
            if (s[i][j] == indexsString[index]) {
                if (indexsString[index] == "华") {//如果第一个汉字就是“华”，那么就是1种走法 直接结束递归
                    return 1;
                } else {//从下面走和从右边的走法的种数相加
                    return (new _03_振兴中华1()).stepForward(i + 1, j,
                            index + 1)
                            + (new _03_振兴中华1()).stepForward(i,
                            j + 1, index + 1);
                }
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println((new _03_振兴中华1()).stepForward(0, 0, 0));
    }
}
